package com.ccb.sc.common.modules.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccb.sc.common.modules.common.entity.LogisticsCompany;
import com.ccb.sc.common.modules.common.mapper.LogisticsCompanyMapper;
import com.ccb.sc.common.modules.common.service.IDeliveryService;
import com.ccb.sc.common.modules.common.vo.QueryTrack;
import com.ccb.sc.common.modules.common.vo.QueryTrackParam;
import com.ccb.sc.common.modules.common.vo.QueryTrackReq;
import com.ccb.sc.common.modules.common.vo.QueryTrackResp;
import com.ccb.sc.common.util.SignUtil;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author ken
 * @version 1.0
 * @date 2020-11-13
 */
@Service
public class DeliveryServiceImpl extends ServiceImpl<LogisticsCompanyMapper, LogisticsCompany> implements IDeliveryService {

    @Value("${kuaidi100.key:QZJDFhkz7742}")
    private String key;
    @Value("${kuaidi100.customer:E8A80EEFF229934270A42AA86C11DB4A}")
    private String customer;
    @Value("${kuaidi100.secret:63121d3918fd49c8b85ef3eac8e4fe88}")
    private String secret;
    @Value("${kuaidi100.userid:d58c615745bb43fabd845cf2071f6f49}")
    private String userid;

    @Override
    public QueryTrackResp queryTrack(String logisticsCompany, String logisticsNo, String phone) {
        QueryTrack queryTrack = new QueryTrack();
        QueryTrackReq queryTrackReq = new QueryTrackReq();
        QueryTrackParam queryTrackParam = new QueryTrackParam();
        queryTrackParam.setCom(logisticsCompany);
        queryTrackParam.setNum(logisticsNo);
        queryTrackParam.setPhone(phone);
        queryTrackReq.setParam(queryTrackParam);
        queryTrackReq.setCustomer(customer);
        queryTrackReq.setSign(SignUtil.sign(new Gson().toJson(queryTrackParam)+key+customer));
        return queryTrack.queryTrack(queryTrackReq);
    }

}
